﻿/*
 *
 */
 
 function ResizeImg(ImgD,xx,yy){
         var image=new Image();
         image.src=ImgD.src;              
         if(image.width>0 && image.height>0){  
          if(image.width/image.height>= xx/yy){
           if(image.width>xx){  
            ImgD.width=xx;
            ImgD.height=(image.height*xx)/image.width;
           }
           else{
            ImgD.width=image.width;  
            ImgD.height=image.height;
           }
         
          }
          else{
           if(image.height>yy){  
            ImgD.height=yy;
            ImgD.width=(image.width*yy)/image.height;     
           }
           else{
            ImgD.width=image.width;  
            ImgD.height=image.height;
           }            
          }
         }
  } 
 
 
 
function openWin(f,n,w,h,s){
	sb = s == "1" ? "1" : "0";
	l = (screen.width - w)/2;
	t = (screen.height - h)/2;
	sFeatures = "left="+ l +",top="+ t +",height="+ h +",width="+ w
			+ ",center=1,scrollbars=" + sb + ",status=0,directories=0,channelmode=0";
	openwin = window.open(f , n , sFeatures );
	if (!openwin.opener)
		openwin.opener = self;
	openwin.focus();
	return openwin;
}

function replaceStr( str ) {
    var re="/( )/gi";
    str = str.replace(re,"");
    re="/\</gi";
    str = str.replace(re,"&lt;");

    return str;
}

/*
 * ȥ����߿ո�
 */
function LTrim(str) {
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(0)) != -1) {
        var j=0, i = s.length;
        while (j < i && whitespace.indexOf(s.charAt(j)) != -1) {
           j++;
        }
        s = s.substring(j, i);
    }
    return s;
}

/*
 * ȥ���ұ߿ո�
 */
function RTrim(str) {
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
        var i = s.length - 1;
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
            i--;
        }
        s = s.substring(0, i+1);
    }
    return s;
}

/*
 * ȥ��}�߿ո�
 */
function Trim(str) {
    return RTrim(LTrim(str));
}

/*
 *
 */
function exeOperation( exePath ){
    var obj = new ActiveXObject("Microsoft.XMLHTTP");
    obj.open("post",exePath,false);
    obj.send();
    var res = obj.responseText;
    var rs = Trim(res);
    if (rs.indexOf('true',0) != -1) {
    	return true;
    } else {
        return false;
    }
}

/*
 *
 */
function exeValidate( exePath ){
    var obj = new ActiveXObject("Microsoft.XMLHTTP");
    obj.open("post",exePath,false);
    obj.send();
    var res = obj.responseText;
    var rs = Trim(res);
    if (rs.indexOf('validate_login_user',0) != -1) {
    	return true;
    } else {
        return false;
    }
}

/*
 * ��ʾ
 */
function validate_date( exePath ) {
	 var obj = new ActiveXObject("Microsoft.XMLHTTP");
     obj.open("post",exePath,false);
     obj.send();
     var res = obj.responseText;
     var rs = Trim(res);
	 var begin_str = "<!--begin-->";
	 var beginIndex = rs.indexOf(begin_str) + begin_str.length;
	 var endIndex   = rs.indexOf("<!--end-->");
	 rs = ((beginIndex >= 0) && (endIndex >= 0)) ? rs.substring(beginIndex,endIndex) : "";
	 return Trim(rs);
}

/*
 * У���Ƿ�����
 */
function checkNumber(name, TempS) {
	for(Count=0;Count<TempS.length;Count++) {
		TempChar=TempS.substring(Count,Count+1);
		RefString="0123456789";
		if (RefString.indexOf(TempChar,0)==-1) {
			alert("����������");
			eval("document.all." + name).focus();
			return false;
		}
	}
}



